package dietAndroidClient;

import com.mnk.TCPsoketTest.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

public class ItemPageActivity extends Activity implements OnClickListener{
	
	private TextView text01;
	private TextView text02;
	private TextView text03;
	private TextView text04;
	
	private Button calButton;
	private Button rankingButton;
	private Button settingButton;
	private Button addButton;
	private Button mainButton;
	
	private ProgressBar progBar;
	
	@Override
	  public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.itempage);
	   
	    mainButton = (Button)findViewById(R.id.button1);
	    calButton = (Button)findViewById(R.id.button2);
	    rankingButton = (Button)findViewById(R.id.button3);
	    settingButton = (Button)findViewById(R.id.button4);
	    addButton =(Button)findViewById(R.id.button5);
	    
	    mainButton.setOnClickListener(this);
	    calButton.setOnClickListener(this);
	    rankingButton.setOnClickListener(this);
	    settingButton.setOnClickListener(this);
	    addButton.setOnClickListener(this);
	    
	    text01 = (TextView)findViewById(R.id.textView1);
	    text02 = (TextView)findViewById(R.id.textView2);
	    text03 = (TextView)findViewById(R.id.textView3);
	    text04 = (TextView)findViewById(R.id.textView4);
	    progBar = (ProgressBar)findViewById(R.id.progressBar2);
	    
	    Bundle bundle = this.getIntent().getExtras();
	    String datePeriod = bundle.getString("datePeriod");
	    String goalAndDay = bundle.getString("goalAndDay");
	    String dateProgress = bundle.getString("dateProgress");
	    String accumNumber = bundle.getString("accumNumber");
	    
	    text01.setText(goalAndDay);
	    text02.setText(dateProgress);
	    text03.setText(accumNumber);
	    text04.setText(datePeriod);
	    text04.setTextSize(16);
	    progBar.setProgress((int)(bundle.getDouble("progress") * 100));
	    
	}

	@Override
	public void onClick(View v) {
		
		switch(v.getId()) {
		case R.id.button1:
			Intent main = new Intent(this, DietClient.class);
		    startActivity(main);
		    finish();
			break;
		case R.id.button2:
			Intent cal = new Intent(this, CalendarView.class);
		    startActivity(cal);
		    finish();
			break;
		case R.id.button3:
			Intent rank = new Intent(this, RankActivity.class);
			startActivity(rank);
			finish();
			break;
		case R.id.button4:
			Intent set = new Intent(this, SettingActivity.class);
			startActivity(set);
			finish();
			break;
		case R.id.button5:
			Intent add = new Intent(this, AddActivity.class);
			startActivity(add);
			finish();
			break;
		}
		
	}

}